package nowcoder.written_examination.huawei;

import java.util.Scanner;
import java.util.TreeSet;

/**
 * @author fance
 * @date 18-6-29 上午6:08
 */
public class MainI {
    public static void main(String[] args) {
//        b();
    a();
    }

        private static void a() {
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNext()) {
                int n = scanner.nextInt();
                if (n == 0) {
                    return;
                }
                System.out.println(a_core(n));
            }
        }
    private static int a_core(int n) {
        if (n < 2) {
            return 0;
        }
        if (n == 2) {
            return 1;
        }
        int res = 0;
        while (n > 2) {
            res += n / 3;
            n = n % 3 + n / 3;
        }
        if (n == 2) {
            res++;
        }
        return res;
    }
        private static void b() {
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNext()) {
                int n = scanner.nextInt();
                TreeSet<Integer> treeSet = new TreeSet<>();
                for (int i = 0; i < n; i++) {
                    treeSet.add(scanner.nextInt());
                }
                for (int num : treeSet) {
                    System.out.println(num);
                }
            }
        }
        private static void c() {
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNext()) {
                String src = scanner.next();
                System.out.println(Integer.parseInt(src.substring(2),16));
            }
        }
}
